/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package net.worlds.object;

import net.worlds.WorldsException;
import net.worlds.Main;


public class AssetService extends GameObject{
    public AssetService() throws WorldsException
    {
        super("AssetService");
        explorable = false;
        //x_;
    }
    @Override
    public void addToWorld() throws WorldsException
    {
        if(world == Main.getGame().getMainWorld())
        {
            addSound("Click");
            addSound("Click2");
            addSound("Explode");
            addSound("Tick");
            addSound("Rocket");
            addSound("BigExplode");
        }
    }
    private void addSound(String name) throws WorldsException
    {
        Sound s = (Sound) world.createObject("Sound");
        s.setProp("Name", name, true);
        s.setProp("Sound", "resource://sounds/"+name+".wav", true);
        s.setParent(this);
    }
    public void playSound(String name) throws WorldsException
    {
        if(hasChild(name))
            ((Sound)getChild(name)).play();
    }
}
